/*
 * @Description: 
 * @Author: mxy
 * @Date: 2022-11-17 21:01:26
 * @LastEditors: mxy
 * @LastEditTime: 2022-11-17 21:57:38
 */
const lineChart = () => {
    const mychart = echarts.init(document.querySelector('#line'))
    const option = {
        title: {
            text: '2022全学科薪资走势',
            top: 15,
            left: 10,
            textStyle: {
                fontSize: 16
            }
        },
        xAxis: {
            type: 'category',
            data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
            axisLabel: {
                color: '#999'
            },
            axisLine: {
                lineStyle: {
                    color: '#ccc',
                    type: 'dotted'
                }
            }
        },
        yAxis: {
            type: 'value',
            splitLine: {
                lineStyle: {
                    type: 'dotted'
                }
            }
        },
        tooltip: {
            trigger: 'axis'
        },
        grid: {
            top: '20%'
        },
        color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [{
                offset: 0, color: '#499FEE' // 0% 处的颜色
            }, {
                offset: 1, color: '#5D75F0' // 100% 处的颜色
            }],
            global: false // 缺省为 false
        },
        series: [
            {
                data: [9000, 12000, 15000, 13000, 10000, 18000, 14000, 10000, 12000, 13000, 15000, 19000],
                type: 'line',
                smooth: true,
                lineStyle: {
                    width: 6
                },
                symbolSize: 10,
                areaStyle: {
                    color: {
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [{
                            offset: 0, color: '#499FEE' // 0% 处的颜色
                        }, {
                            offset: 0.8, color: 'rgba(255,255,255,0.2)' // 80% 处的颜色
                        }, {
                            offset: 1, color: 'rgba(255,255,255,0)' // 100% 处的颜色
                        }],
                        global: false // 缺省为 false
                    }
                }
            }
        ]
    }
    mychart.setOption(option)
}
lineChart()

const classSalary = () => {
    const mychart = echarts.init(document.querySelector('#salary'))
    const option = {
        title: {
            text: '班级薪资分布',
            top: 15,
            left: 10,
            textStyle: {
                fontSize: 16
            }
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            bottom: '6%',
            left: 'center',
            itemWidth: 15
        },
        series: [
            {
                name: '班级薪资分布',
                type: 'pie',
                radius: ['50%', '64%'],
                itemStyle: {
                    borderRadius: 10,
                    borderColor: '#fff',
                    borderWidth: 2
                },
                label: {
                    show: false,
                    position: 'center'
                },

                labelLine: {
                    show: false
                },
                data: [
                    { value: 1048, name: '1万以下' },
                    { value: 235, name: '1万-2万' },
                    { value: 580, name: '1.5万-2万' },
                    { value: 484, name: '2万以上' }
                ]
            }
        ],
        color: ['#FDA224', '#5097FF', '#3ABCFA', '#34D39A']
    }
    mychart.setOption(option)
}
classSalary()

const sexSalary = () => {
    const mychart = echarts.init(document.querySelector('#gender'))
    const option = {
        title: [{
            text: '男女薪资分布',
            top: 10,
            left: 10,
            textStyle: {
                fontSize: 16
            }
        },
        {
            text: '男生',
            top: '50%',
            left: '45%',
            textStyle: {
                fontSize: 12
            }
        },
        {
            text: '女生',
            top: '90%',
            left: '45%',
            textStyle: {
                fontSize: 12
            }
        }
        ],
        tooltip: {
            trigger: 'item'
        },
        series: [
            {
                name: '男生薪资分布',
                type: 'pie',
                radius: ['20%', '30%'],
                center: ['50%', '30%'],
                data: [
                    { value: 1048, name: '1万以下' },
                    { value: 235, name: '1万-2万' },
                    { value: 580, name: '1.5万-2万' },
                    { value: 484, name: '2万以上' }
                ]
            },
            {
                name: '女生薪资分布',
                type: 'pie',
                radius: ['20%', '30%'],
                center: ['50%', '70%'],
                data: [
                    { value: 1048, name: '1万以下' },
                    { value: 235, name: '1万-2万' },
                    { value: 580, name: '1.5万-2万' },
                    { value: 484, name: '2万以上' }
                ]
            }
        ],
        color: ['#FDA224', '#5097FF', '#3ABCFA', '#34D39A']
    }
    mychart.setOption(option)
}
sexSalary()

const map = () => {
    const mapData = [
        { name: '南海诸岛', value: 0 },
        { name: '北京', value: 3 },
        { name: '天津', value: 2 },
        { name: '上海', value: 4 },
        { name: '重庆', value: 1 },
        { name: '河北', value: 20 },
        { name: '河南', value: 23 },
        { name: '云南', value: 0 },
        { name: '辽宁', value: 15 },
        { name: '黑龙江', value: 12 },
        { name: '湖南', value: 2 },
        { name: '安徽', value: 5 },
        { name: '山东', value: 18 },
        { name: '新疆', value: 0 },
        { name: '江苏', value: 5 },
        { name: '浙江', value: 1 },
        { name: '江西', value: 4 },
        { name: '湖北', value: 3 },
        { name: '广西', value: 2 },
        { name: '甘肃', value: 9 },
        { name: '山西', value: 11 },
        { name: '内蒙古', value: 14 },
        { name: '陕西', value: 14 },
        { name: '吉林', value: 10 },
        { name: '福建', value: 0 },
        { name: '贵州', value: 0 },
        { name: '广东', value: 0 },
        { name: '青海', value: 3 },
        { name: '西藏', value: 0 },
        { name: '四川', value: 1 },
        { name: '宁夏', value: 1 },
        { name: '海南', value: 0 },
        { name: '台湾', value: 0 },
        { name: '香港', value: 0 },
        { name: '澳门', value: 0 }
    ]
    const mychart = echarts.init(document.querySelector('#map'))
    const option = {
        series: [{
            type: 'map',
            map: 'china',
            name: '籍贯分布',
            label: {
                show: 'true',
                fontSize: 10,
                color: 'rgba(0,0,0,0.7)'
            },
            itemStyle: {
                borderColor: 'rgba(0, 0, 0, 0.2)',
                areaColor: '#E0FFFF'
            },
            emphasis: {
                itemStyle: {
                    areaColor: '#34D39A',
                    borderWidth: 0,
                    shadowBlur: 20,
                    shadowOffsetX: 0,
                    shadowOffsetY: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            },
            data: mapData
        }],
        title: {
            text: '籍贯分布',
            top: 10,
            left: 10,
            textStyle: {
                fontSize: 16
            }
        },
        tooltip: {
            formatter: '{b}: {c}位学员',
            borderColor: 'transparent',
            backgroundColor: 'rgba(0,0,0,0.5)',
            textStyle: {
                color: '#fff'
            }
        },
        visualMap: [{
            type: 'continuous',
            max: 20,
            min: 0,
            text: [20, 0],
            left: 40,
            bottom: 20,
            inRange: {
                color: ['#fff', '#0075F0'],
            }
        }]
    }
    mychart.setOption(option)
}
map()

const groupSalaryChart = () => {
    const myChart = echarts.init(document.querySelector('#lines'))
    const option = {
        xAxis: {
            type: 'category',
            data: ['杨志浩', '董萍', '余先燕', '贾泰', '李宁', '杨忠午', '李敬', '何顺', '朱鑫海'],
            axisLine: {
                lineStyle: {
                    color: '#ccc',
                    type: 'dotted'
                }
            },
            axisLabel: {
                color: '#999'
            }
        },
        yAxis: {
            type: 'value',
            splitLine: {
                lineStyle: {
                    type: 'dotted'
                }
            }
        },
        series: [
            {
                data: [12200, 17932, 13901, 13934, 21290, 23300, 13300, 13320, 13320],
                type: 'bar',
                name: '期望薪资'
            },
            {
                data: [22820, 19932, 16901, 15934, 31290, 13300, 14300, 18320, 20000],
                type: 'bar',
                name: '就业薪资'
            }
        ],
        grid: {
            left: 70,
            top: 30,
            right: 30,
            bottom: 50
        },
        tooltip: {},
        color: [
            {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [{
                    offset: 0, color: '#34D39A' // 0% 处的颜色
                }, {
                    offset: 1, color: 'rgba(52,211,154,0.2)' // 100% 处的颜色
                }],
                global: false // 缺省为 false
            },
            {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [{
                    offset: 0, color: '#499FEE' // 0% 处的颜色
                }, {
                    offset: 1, color: 'rgba(73,159,238,0.2)' // 100% 处的颜色
                }],
                global: false // 缺省为 false
            },
        ]

    }
    myChart.setOption(option)
}
groupSalaryChart()
